package com.school.controller.student;

import com.school.model.Student;
import com.school.service.StudentService;
import com.school.service.impl.StudentServiceImpl;
import com.school.util.RequestJsonUtil;
import com.school.util.ResponseJsonUtil;
import com.school.vo.R;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/student/updates")
public class UpdatesController extends HttpServlet {
    StudentService studentService = new StudentServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Student> read = RequestJsonUtil.read(req, Student.class);
        // 调用Service中的方法
        studentService.update(read);
        ResponseJsonUtil.write(resp, R.ok());
    }
}
